import tkinter as tk
from tkinter import ttk, messagebox
import webbrowser

class VideoDownloaderApp:
    def __init__(self, root):
        self.root = root
        self.root.title("视频链接解析器")
        self.root.geometry("500x250")

        self.create_widgets()

    def create_widgets(self):
        ttk.Label(self.root, text="请输入视频网址:").pack(pady=10)

        self.entry = ttk.Entry(self.root, width=50)
        self.entry.pack(padx=20, pady=5)

        ttk.Label(self.root, text="选择解析接口:").pack(pady=5)

        self.api_options = [
            ("CK解析 (有广告)", "https://www.ckplayer.vip/jiexi/?url=")
        ]

        self.selected_api = tk.StringVar()
        self.selected_api.set(self.api_options[0][1])

        self.radio_frame = ttk.Frame(self.root)
        self.radio_frame.pack(pady=5)
        for text, mode in self.api_options:
            ttk.Radiobutton(self.radio_frame, text=text, variable=self.selected_api, value=mode).pack(side="left", padx=10, pady=5)

        ttk.Button(self.root, text="解析", command=self.parse_video).pack(pady=10)

    def parse_video(self):
        video_url = self.entry.get().strip()
        selected_api = self.selected_api.get()

        if not video_url:
            messagebox.showerror("错误", "请输入视频网址")
            return

        api_url = selected_api + video_url
        webbrowser.open(api_url)

if __name__ == "__main__":
    root = tk.Tk()
    app = VideoDownloaderApp(root)
    root.mainloop()